<template>
	<view class="container">
		<uni-card :title="item.title" thumbnail="" :extra="item.name" note="Tips"
			v-for="item,index in commentlist">
			{{item.content}}
		</uni-card>
	</view>
</template>

<script>
	export default {
		onReachBottom() {
			this.loadmore()
		},
		onPullDownRefresh() {
			this.reload()
		},
		onLoad() {
			this.reload()
		},
		data() {
			return {
				Id: 1,
				pageIndex: 0,
				pageSize: 10,
				commentlist: [{
						"id": 1,
						"title": "标题",
						"content": "学校的篮球场太棒了，专业级别，自由飞翔！",
						"date": "2019-07-19",
						"name": "张三"
					},
					{
						"id": 2,
						"title": "学校的二楼的罗宋汤太棒了",
						"content": "酸、甜、辣、咸，就差一样苦，四味俱全！",
						"date": "2019-07-20",
						"name": "张"
					}
				]
			}
		},
		methods: { //加载更多

			loadmore() {
				uni.showLoading({
					title: '加载新的一页',
					mask: false
				});
				uni.request({
					url: 'http://localhost:8090/freshmenapp/message/list',
					method: 'POST',
					data: {
						"Id": this.title,
						"pageIndex": ++this.pageIndex,
						"pageSize": this.pageSize
					},
					success: res => {
						//拼接数据
						this.name = null
						this.commentlist = this.commentlist.concat(res.data.list)
					},
					fail: () => {},
					complete: () => {
						setTimeout(() => {
							uni.hideLoading()
						}, 2000)
					},
				});
			},
			reload() {
				uni.request({
					url: 'http://localhost:8090/freshmenapp/message/list',
					method: 'POST',
					data: {
						"Id": this.title,
						"pageIndex": 0,
						"pageSize": this.pageSize
					},
					success: res => {
						console.log(res)
						this.commentlist = res.data.list
						
					},
					fail: () => {

					},
					complete: () => {
						uni.stopPullDownRefresh()
					},
				})

			},
		}

	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>